<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
        <h:form>
            <p:panel id="panelPrint" styleClass="noBorder summeryBorder">
                <h:panelGrid columns="8" styleClass="noPrintButton">
                    <h:outputLabel value="From Date"/>
                    <p:calendar value="#{pharmacySaleReport.fromDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss a"  >
                    </p:calendar>
                    <h:outputLabel value="To Date"/>
                    <p:calendar value="#{pharmacySaleReport.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss a" >
                    </p:calendar>
                    <h:outputLabel value="Instituion"/>
                    <p:autoComplete styleClass="noPrintButton"  value="#{pharmacySaleReport.institution}"  
                                    style="text-align: left; margin: 5px; padding: 5px;"  completeMethod="#{institutionController.completeCompany}" var="dept" itemValue="#{dept}" itemLabel="#{dept.name}" forceSelection="true" rendered="true" requiredMessage="You must select Institution" >
                    </p:autoComplete>
                    <h:outputLabel value="Departmant"/>
                    <p:autoComplete styleClass="noPrintButton"  value="#{pharmacySaleReport.department}"  
                                    style="text-align: left; margin: 5px; padding: 5px;"  completeMethod="#{departmentController.completeDept}" var="dep" itemValue="#{dep}" itemLabel="#{dep.name}" forceSelection="true" rendered="true" requiredMessage="You must select a department" >
                    </p:autoComplete>

                </h:panelGrid>

                <h:panelGrid columns="3">
                    <p:commandButton ajax="false" value="Process" action="#{pharmacySaleReport.createDailyOpdFeeSummeryWithCounts}"/>
                    <p:commandButton ajax="false" value="Excel" actionListener="#{pharmacySaleReport.createLabReportByDate}" styleClass="noPrintButton" style="float: right;" >
                        <pe:exporter type="xlsx" target="sum1" fileName="report_pharmacy_sale_by_date_summery"  />
                    </p:commandButton>
                    <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" >
                        <p:printer target="panelPrint" />
                    </p:commandButton>
                </h:panelGrid>

                <h:panelGrid styleClass="printBlock" columns="2">
                    <h:outputLabel value="#{pharmacySaleReport.department.name}"/>
                    <h:outputLabel value="LAB HAND OVER REPORT SUMMERY"/>                   
                    <h:outputLabel value="From Date :  "/>
                    <h:outputLabel value="#{pharmacySaleReport.fromDate}"  >
                        <f:convertDateTime pattern="dd MMMM yyyy" />
                    </h:outputLabel>
                    <h:outputLabel value="To Date"/>
                    <h:outputLabel value="#{pharmacySaleReport.toDate}"  >
                        <f:convertDateTime pattern="dd MMMM yyyy" />
                    </h:outputLabel>                       
                </h:panelGrid>


                <p:dataTable id="sum1" value="#{pharmacySaleReport.billedSummery.bills}" var="i">   
                    <f:facet name="header">
                        <p:outputLabel value="#{pharmacySaleReport.institution.name} Summary Report By Date" />
                        <h:outputLabel value="From : "/>
                        <h:outputLabel value="#{pharmacySaleReport.fromDate}">
                            <f:convertDateTime pattern="dd MMMM yyyy HH:mm:ss a"/>
                        </h:outputLabel>
                        <h:outputLabel value="To :"/>
                        <h:outputLabel value="#{pharmacySaleReport.toDate}">
                            <f:convertDateTime pattern="dd MMMM yyyy HH:mm:ss a"/>
                        </h:outputLabel>
                    </f:facet>

                    <p:column headerText="Date">
                        <f:facet name="header">
                            <h:outputLabel value="Date" />
                        </f:facet>
                        <h:outputLabel value="#{i.string}" />
                    </p:column>
                    <p:column headerText="Hospital Fee" style="text-align: right;">
                        <f:facet name="header">
                            <h:outputLabel value="Hospital Fee" />
                        </f:facet>
                        <h:outputLabel value="#{i.value1}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="Regent Fee" style="text-align: right;">
                        <f:facet name="header">
                            <h:outputLabel value="Regent Fee" />
                        </f:facet>
                        <h:outputLabel value="#{i.value2}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="Professional Fee" style="text-align: right;">
                        <f:facet name="header">
                            <h:outputLabel value="Professional Fee" />
                        </f:facet>
                        <h:outputLabel value="#{i.value3}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="Net Value" style="text-align: right;">
                        <f:facet name="header">
                            <h:outputLabel value="Net Value" />
                        </f:facet>
                        <h:outputLabel value="#{i.value1+i.value2+i.value3}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>

                    <p:columnGroup type="footer">
                        <p:row>
                            <p:column footerText="Total  "/>
                            <p:column footerText="#{pharmacySaleReport.billedSummery.billedTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.billedSummery.billedTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.billedSummery.refundedTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.billedSummery.refundedTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.billedSummery.cancelledTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.billedSummery.cancelledTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>

                            <p:column footerText="#{pharmacySaleReport.billedSummery.billedTotal+pharmacySaleReport.billedSummery.cancelledTotal+pharmacySaleReport.billedSummery.refundedTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.billedSummery.billedTotal+pharmacySaleReport.billedSummery.cancelledTotal+pharmacySaleReport.billedSummery.refundedTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>

                        </p:row>
                    </p:columnGroup>

                </p:dataTable>
                <p:spacer height="30px"/>
                
                <p:dataTable value="#{pharmacySaleReport.labBhtIssueBilledBills}" var="bi" id="tbl" style="text-align: right">
                    <f:facet name="header">
                        <h:outputLabel value="BHT Issue"></h:outputLabel>
                    </f:facet>

                    <p:column headerText="Bill No" style="text-align: left!important">
                        <h:outputLabel value="#{bi.insId}"></h:outputLabel>
                    </p:column>

                    <p:column headerText="Created At"  style="text-align: left!important">
                        <h:outputLabel value="#{bi.createdAt}">
                            <f:convertDateTime pattern="dd MM yy HH:mm:ss"/>
                        </h:outputLabel>
                    </p:column>

                    <p:column headerText="BHT No">
                        <h:outputLabel value="#{bi.patientEncounter.bhtNo}"></h:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="Total"/>
                        </f:facet>
                    </p:column>

                    <p:column headerText="Amount"  style="text-align: right!important">
                        <h:outputLabel value="#{bi.netTotal}"></h:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="#{pharmacySaleReport.labBhtIssueBilledBillTotals}"/>
                        </f:facet>
                    </p:column>

                </p:dataTable>



            </p:panel>
            <p:panelGrid columns="2">
                <h:outputLabel value="Hospital Fee Total"/>
                <h:outputLabel value="#{pharmacySaleReport.billedSummery.billedTotal}"/>
                
                <h:outputLabel value="Regent Fee Total"/>
                <h:outputLabel value="#{pharmacySaleReport.billedSummery.refundedTotal}"/>
                
                <h:outputLabel value="Professional Fee Total"/>
                <h:outputLabel value="#{pharmacySaleReport.billedSummery.cancelledTotal}"/>
                
                <h:outputLabel value="BHT Issue Total"/>
                <h:outputLabel value="#{pharmacySaleReport.labBhtIssueBilledBillTotals}"/>
                
                <h:outputLabel value="Net Total"/>
                <h:outputLabel style="font-size: large; color: blue; font-style: italic" value="#{pharmacySaleReport.billedSummery.billedTotal + 
                                        pharmacySaleReport.billedSummery.refundedTotal + 
                                        pharmacySaleReport.billedSummery.cancelledTotal + 
                                        pharmacySaleReport.billedSummery.cancelledTotal + 
                                        pharmacySaleReport.labBhtIssueBilledBillTotals}"/>
            </p:panelGrid>


        </h:form>

    </ui:define>



</ui:composition>
